// subPackages/packageA/components/shesuPreview.ts
import { getSxStatBaseInfoAPI } from "../../api/shesu"
import { debtorPrice } from "../../../../utils/util"
Component({
  options: {
    styleIsolation: "apply-shared"
  },
  /**
   * 组件的属性列表
   */
  properties: {
    debtorId: {
      type: String,
      value: ""
    },
    companyName: {
      type: String,
      value: ""
    },
    businessType: {
      type: String,
      value: "1"
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    baseInfo: {}
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 获取涉诉基础信息
    async getSxStatBaseInfo() {
      const { content }: any = await getSxStatBaseInfoAPI({ id: this.data.debtorId, businessType: this.data.businessType })
      content.totalAmount = content.totalAmount && debtorPrice(content.totalAmount)
      this.setData({
        baseInfo: content || {}
      })
    },
    // 跳转
    checkMore() {
      wx.navigateTo({
        url: "/subPackages/packageA/shesu/shesuAnalysis/shesuAnalysis?debtorId=" + this.data.debtorId + "&companyName=" + this.data.companyName

      })
    }
  },
  observers: {
    'debtorId': function () {
      // console.log(this.data.debtorId, "debtorId")
      if (this.data.debtorId) {
        this.getSxStatBaseInfo()
      }
    }
  },
  // 组件的的生命周期
  lifetimes: {
    // 在组件实例进入页面节点树时执行
    attached: function () {

    }
  }
})